home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung CD 2 (Tewi)(1994).iso / doc / ems / disk3 / emm27_b.asm < prev    next >
Assembly Source File  |  1989-11-29  |  12KB  |  182 lines

  1. ;-----------------------------------------------------------------------------;
  2. ;      MODULE NAME:   EMM27_B.ASM                                             ;
  3. ;                                                                             ;
  4. ;    FUNCTION NAME:   alloc_raw_pages                                         ;
  5. ;                                                                             ;
  6. ;                     The alloc_raw_pages function allocates the number of    ;
  7. ;                     non-standard size pages that the operating system       ;
  8. ;                     requests and assigns a unique EMM handle to these       ;
  9. ;                     pages.  The EMM handle owns these pages until the       ;
  10. ;                     operating system deallocates them.                      ;
  11. ;                                                                             ;
  12. ;                     This function allows you to allocate zero pages to a    ;
  13. ;                     handle, unlike the alloc_pages function.                ;
  14. ;                                                                             ;
  15. ;                     A hardware vendor may design an expanded memory board   ;
  16. ;                     that has a page size which is a sub-multiple of 16K     ;
  17. ;                     bytes.  A physical page which is a sub-multiple of 16K  ;
  18. ;                     is termed a raw page.  The operating system may deal    ;
  19. ;                     with page sizes which are sub-multiples of 16K bytes.   ;
  20. ;                     The memory manager must treat any function using a      ;
  21. ;                     handle with raw pages allocated to it by                ;
  22. ;                     alloc_raw_pages differently than it does a handle that  ;
  23. ;                     has normal 16K-byte pages allocated to it.              ;
  24. ;                                                                             ;
  25. ;                     Handles which are assigned using alloc_pages or         ;
  26. ;                     alloc_std_pages must have pages which are 16K bytes --  ;
  27. ;                     this is the length of a standard expanded memory page.  ;
  28. ;                     If the expanded memory board hardware is not able to    ;
  29. ;                     supply 16K-byte pages, the memory manager must emulate  ;
  30. ;                     pages which are 16K bytes combining multiple            ;
  31. ;                     non-standard size pages to form a single 16K-byte page. ;
  32. ;                     Handles which are assigned using alloc_raw_pages are    ;
  33. ;                     called raw handles.  All logical pages allocated to a   ;
  34. ;                     raw handle may have a non-standard length (that is, not ;
  35. ;                     16K bytes).  However, once the operating system has     ;
  36. ;                     allocated a number of raw pages to a handle, it is the  ;
  37. ;                     responsibility of the memory manager to recognize that  ;
  38. ;                     raw handle as one that has non-standard size pages      ;
  39. ;                     allocated to it.  The memory manager must identify      ;
  40. ;                     these handles and treat all functions which use handles ;
  41. ;                     which have non-standard page lengths differently.  The  ;
  42. ;                     logical page length becomes the length of the           ;
  43. ;                     non-standard size page for any raw handle that          ;
  44. ;                     alloc_raw_pages assigns.                                ;
  45. ;                                                                             ;
  46. ;                     Note:                                                   ;
  47. ;                        This note affects expanded memory manager            ;
  48. ;                        implementers and operating system developers only.   ;
  49. ;                        Applications should not use the following            ;
  50. ;                        characteristic of the memory manager.  An            ;
  51. ;                        application violating this rule will be incompatible ;
  52. ;                        with future versions of Microsoft's operating        ;
  53. ;                        systems and environments.                            ;
  54. ;                                                                             ;
  55. ;                        To be compatible with this specification, an         ;
  56. ;                        expanded memory manager will provide a special       ;
  57. ;                        handle which is available to the operating system    ;
  58. ;                        only.  This handle will have a value of 0 and        ;
  59. ;                        will have a set of pages allocated to it when the    ;
  60. ;                        expanded memory manager driver installs.  The pages  ;
  61. ;                        that the memory manager will automatically allocate  ;
  62. ;                        to handle 0 are those that it has mapped into        ;
  63. ;                        conventional memory.                                 ;
  64. ;                                                                             ;
  65. ;                        An operating system won't have to invoke the         ;
  66. ;                        alloc_raw_pages function to obtain this handle       ;
  67. ;                        because it can assume the handle already exists and  ;
  68. ;                        is available for use immediately after the expanded  ;
  69. ;                        memory device driver installs.  When an operating    ;
  70. ;                        system wants to use this handle, it uses the special ;
  71. ;                        handle value of 0. The operating system will be able ;
  72. ;                        to invoke any EMM function using this special handle ;
  73. ;                        value.  To allocate pages to this handle, the        ;
  74. ;                        operating system need only invoke realloc_pages      ;
  75. ;                        function.                                            ;
  76. ;                                                                             ;
  77. ;                        There are two special cases for this handle:         ;
  78. ;                        1. alloc_raw_pages: when invoked, must never return  ;
  79. ;                           zero as a handle value.  Applications must always ;
  80. ;                           invoke alloc_std_pages to allocate pages and      ;
  81. ;                           obtain a handle which identifies the pages which  ;
  82. ;                           belong to it.  Since alloc_std_pages never        ;
  83. ;                           returns a handle value of zero, an application    ;
  84. ;                           will never gain access to this special handle.    ;
  85. ;                                                                             ;
  86. ;                        2. dealloc_pages: if the operating system uses it to ;
  87. ;                           deallocate the pages which are allocated to this  ;
  88. ;                           handle, the pages the handle owns will be         ;
  89. ;                           returned to the manager for use.  But the handle  ;
  90. ;                           will not be available for reassignment.  The      ;
  91. ;                           manager should treat a deallocate pages function  ;
  92. ;                           request for this handle the same as a reallocate  ;
  93. ;                           pages function request, where the number of pages ;
  94. ;                           to reallocate to this handle is zero.             ;
  95. ;                                                                             ;
  96. ;           PASSED:   raw_page_count:                                         ;
  97. ;                        is the number of raw pages the operating system      ;
  98. ;                        wants to allocate.                                   ;
  99. ;                                                                             ;
  100. ;                     &handle:                                                ;
  101. ;                        is a far pointer to a unique handle which the memory ;
  102. ;                        manager will assign to the block of pages allocated  ;
  103. ;                        to the operating system.                             ;
  104. ;                                                                             ;
  105. ;         RETURNED:   status:                                                 ;
  106. ;                        is the status EMM returns from the call.  All other  ;
  107. ;                        returned results are valid only if the status        ;
  108. ;                        returned is zero.  Otherwise they are undefined.     ;
  109. ;                                                                             ;
  110. ;                     handle:                                                 ;
  111. ;                        is a unique handle which the memory manager will     ;
  112. ;                        assign to the block of pages allocated to the        ;
  113. ;                        operating system.  The operating system must use     ;
  114. ;                        this EMM handle as a parameter in any function that  ;
  115. ;                        requires it.  Up to 255 handles may be obtained.     ;
  116. ;                        The alloc_pages and alloc_raw_pages functions must   ;
  117. ;                        share the same 255 handles.                          ;
  118. ;                                                                             ;
  119. ;                        For all functions using this raw handle, the length  ;
  120. ;                        of the physical and logical pages allocated to it    ;
  121. ;                        may be non-standard (that is, not 16K bytes).        ;
  122. ;                                                                             ;
  123. ; C USE CONVENTION:   unsigned int status;                                    ;
  124. ;                     unsigned int raw_page_count;                            ;
  125. ;                     unsigned int handle;                                    ;
  126. ;                                                                             ;
  127. ;                     status = alloc_raw_pages (raw_page_count,               ;
  128. ;                                               &handle);                     ;
  129. ;-----------------------------------------------------------------------------;
  130. .XLIST
  131. PAGE    60,132
  132.  
  133. IFDEF SMALL
  134.    .MODEL SMALL, C
  135. ENDIF
  136. IFDEF MEDIUM
  137.    .MODEL MEDIUM, C
  138. ENDIF
  139. IFDEF LARGE
  140.    .MODEL LARGE, C
  141. ENDIF
  142. IFDEF COMPACT
  143.    .MODEL COMPACT, C
  144. ENDIF
  145. IFDEF HUGE
  146.    .MODEL HUGE, C
  147. ENDIF
  148.  
  149. INCLUDE emmlib.equ
  150. INCLUDE emmlib.str
  151. INCLUDE emmlib.mac
  152. .LIST
  153. .CODE
  154.  
  155. alloc_raw_pages        PROC                                                  \
  156.             raw_page_count:WORD,                                  \
  157.             ptr_handle:FAR PTR WORD
  158.  
  159.     ;---------------------------------------------------------------------;
  160.     ;   do;                                                               ;
  161.     ;   .   allocate the number of specified RAW pages from EMM;          ;
  162.     ;---------------------------------------------------------------------;
  163.     MOVE        AX, alloc_raw_pages_fcn
  164.     MOVE        BX, raw_page_count
  165.     INT         EMM_int
  166.  
  167.     ;---------------------------------------------------------------------;
  168.     ;   .   pass the handle back to the caller;                           ;
  169.     ;---------------------------------------------------------------------;
  170.     MOVE        ES:BX, ptr_handle
  171.     MOVE        ES:[BX], DX
  172.  
  173.     ;---------------------------------------------------------------------;
  174.     ;   .   return (EMM status);                                          ;
  175.     ;   end;                                                              ;
  176.     ;---------------------------------------------------------------------;
  177.     RET_EMM_STAT    AH
  178.  
  179. alloc_raw_pages        ENDP
  180.  
  181. END
  182.